﻿using Autofac;
using Bmz.Studio.Core;
using Bmz.Studio.EntityFramework;
using Bmz.Studio.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Bmz.Studio.Web
{
    public class StudioDependencyRegistrar : IDependencyRegistrar
    {
        public void Register(ContainerBuilder builder, ITypeFinder typeFinder)
        {
            builder.RegisterType<StudioObjectContext>().As<IDbContext>().InstancePerLifetimeScope();
            builder.RegisterInstance(typeFinder).As<ITypeFinder>().SingleInstance();
            builder.RegisterGeneric(typeof(EfRepository<>)).As(typeof(IRepository<>)).InstancePerLifetimeScope();
            builder.RegisterType<DictionaryService>().As<IDictionaryService>().InstancePerLifetimeScope();
            builder.RegisterType<NavigationService>().As<INavigationService>().InstancePerLifetimeScope();
            builder.RegisterType<PersonService>().As<IPersonService>().InstancePerLifetimeScope();
        }

        public int Order
        {
            get { return 1; }
        }
    }
}